package service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import pojo.Customer;
import service.CustomerManager;
public class CustomerManagerImpl implements CustomerManager{
	private List<Customer> customers=new ArrayList<Customer>();
	public Customer addCustomer(Customer c) {
		synchronized (customers) {
			c.setId(UUID.randomUUID().toString());
			customers.add(c);
		}
		return c;
	}

	public List<Customer> findAll() {
		return customers;
	}
	public Customer deleteCustomerById(String id) {
		if(null==id){
			return null;
		}
		Customer customer = new Customer(id);
		if(!customers.contains(customer)){
			return null;
		}
		int index = customers.indexOf(customer);
		customer = customers.get(index);
		customers.remove(index);
		return customer;
	}
}
